/*
 * @Description: MCU STD
 * @Author: diyhome
 * @Date: 2020-12-26 22:00
 * @File: mcu_std
*/

#ifndef MPU6050_F4_MCU_STD_H
#define MPU6050_F4_MCU_STD_H
#include "main.h"

//#define ENABLE_NEW_DELETE // 启用new/delete支持

#ifndef ENABLE_NEW_DELETE
#define LENGTH_CHAR 128   // char 数组长度
#endif

namespace mcu_std {
    class _cout {
    public:
        const _cout &operator<<(const int integer) const;
        const _cout &operator<<(const float integer) const;
        const _cout &operator<<(double integer) const;
        const _cout &operator<<(const char *s) const;

        // 获取串口发送句柄,可以直接重写pritnf函数,这样就不用管这个句柄了
        _cout(UART_HandleTypeDef *huart) : uart_handle(huart) {};
        _cout(void (*pointer_print)(char *));

    private:
        UART_HandleTypeDef *uart_handle;

        void __printf(char *pdata) const;
        typedef void (*pointer_printf)(char *);
    };
    extern char *endl;
}

extern mcu_std::_cout cout;
#endif //MPU6050_F4_MCU_STD_H
